package com.nick.singleton;

/**
 * Created by xiaobao on 2017/7/18.
 * 此种方法同样利用类加载机制来获得单例，同时也实现了懒加载因为SingletonHolder只有在被显示调用时才会被加载，是一种
 * 不错的实现方式。
 */
public class Singleton5 {
    private static class SingletonHolder {
        private static final Singleton5 INSTANCE = new Singleton5();
    }

    private Singleton5() {
    }
    public static synchronized Singleton5 getInstance() {
        return SingletonHolder.INSTANCE;
    }
}
